#include<iostream>
#include<queue>
using namespace std;
#define MOD 80112002

const int N = 500010;
int n, m, ep;

struct Edge
{
	int h, t;
	Edge* next;
}edges[N];

struct Node
{
	int in, out, step;
	Edge* first;
}nodes[N];

void addedge(int h, int t)
{
	edges[ep].h = h;
	edges[ep].t = t;
	edges[ep].next = nodes[h].first;
	nodes[h].first = &edges[ep];
	nodes[h].out++;
	nodes[t].in++;
	ep++;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int h, t;
		cin >> h >> t;
		addedge(h, t);
	}
	queue<Node>qu;
	for (int i = 1; i <= n; i++)
	{
		if (!nodes[i].in)
		{
			nodes[i].step = 1;
			qu.push(nodes[i]);
		}
	}
	while (!qu.empty())
	{
		Node top = qu.front();
		qu.pop();
		Edge* e = top.first;
		while (e != NULL)
		{
			nodes[e->t].in--;
			nodes[e->t].step = (nodes[e->t].step + top.step) % MOD;
			if (!nodes[e->t].in)
			{
				qu.push(nodes[e->t]);
			}
			e = e->next;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (!nodes[i].out)
		{
			ans = (ans + nodes[i].step) % MOD;
		}
	}
	cout << ans;
	return 0;
}